#! /bin/sh
set -e

. /usr/share/debconf/confmodule

db_get oem-config-udeb/frontend
apt-install "oem-config${RET:+-$RET lingmo-installer-frontend-$RET}"
if [ "$RET" = gtk ]; then
	apt-install "oem-config-slideshow-lingmo" || true
fi
if [ "$RET" = kde ]; then
	apt-install "lingmo-installer-slideshow-klingmo" || true
fi
# Restore title, since packages with debconf templates may have changed it.
db_settitle debian-installer/finish-install/title

db_input high oem-config-udeb/instructions || true
db_go || true

# Copy the value of debian-installer/locale over to the target system so that
# it gets used by oem-config as the default language selection.
# debian-installer/framebuffer is needed for oem-config-debconf.
db_get debian-installer/locale
LOCALE="$RET"
db_get debian-installer/framebuffer
FRAMEBUFFER="$RET"
chroot /target debconf-set-selections <<EOF || true
oem-config debian-installer/locale select $LOCALE
oem-config debian-installer/framebuffer boolean $FRAMEBUFFER
EOF
# Disable lingmo-installer.service in the installed system as it conflicts with
# getty@tty1.service which we want to run.
chroot /target systemctl mask lingmo-installer.service
